Skip to content

Feat/v5 - #49

Draft
mCodex wants to merge 88 commits into
mainfrom
feat/v5
Draft

Feat/v5#49
mCodex wants to merge 88 commits into
mainfrom
feat/v5

Conversation

@mCodex

@mCodex mCodex commented Jul 20, 2026

Copy link
Copy Markdown
Owner

No description provided.

mCodex added 4 commits July 17, 2026 11:26
…el catalog, model registry, online models, performance budget, replay, resource loot reward, runtime, safety envelope, snapshot builder, tactical blackboard, tactical states, target proposal, UI bridge, and UI presenter

- Implement tests for lifecycle initialization and termination
- Verify loader order for unified tick and event bus
- Ensure metrics maintain bounded counters, gauges, and samples
- Test model catalog registration and lifecycle
- Validate model registry behavior and evidence handling
- Check online models for streaming statistics and Markov state predictions
- Assess performance budget degradation of optional work
- Confirm deterministic replay functionality
- Evaluate resource and loot observation handling
- Test runtime initialization and lifecycle management
- Validate safety envelope for decision-making
- Ensure snapshot builder reconciles spectators correctly
- Test tactical blackboard for owner validation and expiration
- Validate tactical proposal states for lure and pull behaviors
- Ensure target proposal adapts legacy targets correctly
- Verify UI bridge exposes required sections
- Test UI presenter for state mapping and command execution

Update ring buffer utility to export globally and bump version to 5.0.0
…with v5 API updates

- Updated discovery_spec.lua to enhance test coverage for the Discovery orchestrator, including state transitions and policy states.
- Revised readiness_spec.lua to incorporate backward compatibility and new role-based readiness checks.
- Enhanced scheduler_spec.lua with additional tests for action processing, acknowledgment, and backoff mechanisms.
- Improved state_machine_spec.lua to reflect new state definitions and transition logic, including terminal state checks.
- Added comprehensive tests for tactical intelligence in tactical_intelligence_spec.lua, ensuring accurate model diagnostics and unified read models.
- Updated bot_doctor_spec.lua to include new checks for actionable intelligence issues and performance metrics.
- Modified ui_bridge_spec.lua to reflect changes in UI sections for the Tactical Intelligence window.
…ning to Tactical Intelligence

- Deleted HuntAnalyzer and its associated UI components.
- Updated analytics event names to reflect the new Tactical Intelligence framework.
- Refactored intelligence runtime to publish canonical events for session management and loot observation.
- Enhanced model catalog to use a neutral prior for fresh predictions.
- Improved monster profiling by integrating telemetry data into Tactical Intelligence.
- Updated documentation to reflect changes in analytics reporting and module integration.
- Added unit tests for new functionality and legacy cleanup.
@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/v5

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

mCodex and others added 25 commits July 20, 2026 11:50
Defines 20 closure reasons and 5 ambiguous reasons for episode
state machine validation. Provides isValid(), isAmbiguous(), and
all() API. Registered as nExBot.IntelligenceOutcomeReasons.
Defines IntelligenceEventSchema with SCHEMA_VERSION, TYPES enum,
REQUIRED_FIELDS, and validation helpers (isValidType, requiredFieldsFor,
hasField). Tests cover schema version, all 25 types, common fields,
per-type fields, unknown/nil rejection, and global registration.
Implements bounded event deduplication with LRU eviction for the
intelligence pipeline. Tracks both eventId and idempotencyKey with
proper cleanup on eviction. 16 tests covering all API surface.
Removed player:health, player:mana, container:update, and combat:target
from the second EventBus block — they were already handled by the
sectionTracker block above, causing double dirty-marking.
- OutcomeRecord.new(config): create instance
- record:create(config): create outcome with decisionId, actionId, closureReason
- record:validate(outcome): validate well-formed outcome
- record:measure(outcome, key, value): add measurement to outcome
- Validates closureReason against IntelligenceOutcomeReasons
- 20 passing tests, no regressions
Creates core/intelligence/records/decision_record.lua with create, close,
and validate methods. Follows outcome_record.lua patterns. Includes 29
busted tests covering required field validation, decisionType enum
checking, default prediction table, outcome attachment, and global
registration.
- EpisodeBase.new/create/close/validate/isOpen API
- Validates episode types: action, encounter, loot, route_segment, hunt
- Uses IntelligenceOutcomeReasons for closure validation
- Idempotent close (returns unchanged if already closed)
- Non-mutating close (returns copy)
- 24 passing tests
- Tracker.new(config) with episodeBase dependency
- start/close/get/getOpen/stats API
- 17 passing tests
- Tracker manages loot episode lifecycle via EpisodeBase
- API: start, close, get, getOpen, stats
- Validates required fields, rejects duplicate IDs
- Tracks lootLifecycle counters per episode
- 20 passing tests
- Initialize episodeBase, encounterTracker, lootEpisodeTracker,
  routeSegmentTracker, huntTracker in runtime init block
- Add combat:target_changed handler to start encounter episodes
- Add loot:received handler to start loot episodes
- Set/clear sessionId and huntId on session start/end events
- Use dofile fallbacks for test compatibility
- Cost.new(config) with optional initialCosts
- getCost(action, context), recordCost(action, cost), getAverage(action)
- 7 passing tests
- Add optional eventFactory/eventContext params to LootObserver.new()
- Emit loot_item_observed on each item in observe()
- Add moveAttempted() emitting loot_move_attempted
- Add moveVerified() emitting loot_move_verified
- Register as nExBot.IntelligenceLootObserver
- 13 tests passing, no regressions
- Initialize rewardVector and rewardNormalizer after episode tracker
- Add intelligence:encounter_closed event handler
- Update test fixtures to load reward modules
- target_value_model, route_reliability_model, resource_efficiency_model
- timing_model, risk_assessment_model, loot_opportunity_model
- ensemble_meta_model (combines other model predictions)

Each model extracts contextual features and maintains per-model state.
Dynamic dispatch wrappers ensure method overrides work through registry.

Co-Authored-By: opencode <noreply@opencode.ai>
TDD: 6 tests covering construction, gate evaluation, promotion
eligibility, and insufficient data handling.
mCodex added 30 commits July 31, 2026 10:51
OTClient does not expose _G as a global. Use direct global reference
instead, which is already loaded by core/cavebot.lua before this file.
…leanup

analyzer.lua still references styles defined in these .otui files
(MainAnalyzerWindow, HuntingAnalyzer, LootAnalyzer, etc.). The
legacy cleanup removed them assuming the analyzer was replaced by
Tactical Intelligence, but analyzer.lua was never removed.

Updated legacy_cleanup_spec.lua to assert the files exist rather
than asserting they don't.
- Renamed IntelligenceConsoleWindow to IntelligenceDashboardWindow and updated dimensions in ui_bridge.otui.
- Replaced MultilineTextEdit with a Panel for content display in the UI.
- Enhanced attack_fsm.lua to manage target switching and hold acquisition more effectively, introducing new state variables and logic for pending switches.
- Updated attack_coordinator.lua to streamline attack requests through a unified AttackFSM interface.
- Improved reachability_service.lua to invalidate targets on player and creature movement events.
- Modified event_targeting.lua to delegate path validation to TargetReachability and emit events for target sightings.
- Adjusted targeting architecture tests to ensure proper connections between sighting and acquisition processes.
- Updated model_catalog_spec.lua to reflect changes in the number of registered capabilities.
- Enhanced remediation_spec.lua to verify character context normalization and hunt metrics calculations.
- Refined target_proposal_spec.lua to ensure correct targeting logic with the new AttackFSM structure.
- Updated ui_bridge_spec.lua to reflect changes in the UI structure and ensure proper rendering of reports.
…ath strategy

- Introduced `transitions_spec.lua` to test TransitionCoordinator functionality, including Z step handling, timeout scenarios, and unexpected Z classifications.
- Added `wp26_fixture_spec.lua` to ensure WP26 recovery logic does not produce repeated refocus logs without new evidence, validating recovery target selection and command dispatching.
- Refactored `nativePathIsSafe` in `path_strategy.lua` to simplify pathfinding options.
- Removed the `waypoint_navigator.lua` file as part of the navigation system overhaul.
Adds cavebot/session_driver.lua mapping the strict S9 NavigationResult
contract (STEP_DISPATCHED/WAITING_BLOCKER/COMPLETED/FAILED_TERMINAL) onto the
goto callback contract (walking/retry/true/false), wiring it into the goto
callback in cavebot/actions.lua behind the new sessionNav config flag
(default OFF, legacy walkTo path preserved).

legacy_bridge:tick now forwards preempted/combatActive from the caller context
(was hardcoded false) so the session honors combat/manual preemption and never
dispatches movement while attacking. Backward compatible: bare-position callers
unchanged.

Tests: new session_driver_spec (4 specs). Full suite 1398 green; luac -p clean.
Phase 2 (route lifecycle): verified the existing buildRoute wiring (already
called from ensureNavigatorRoute + findReachableWaypoint) drives the session;
added a round-trip test that walks a 3-node route to completion via edge
self-advance (_selectSuccessor) — no redundant production wiring.

Phase 3 (combat preemption): baked into Phase 1 — goto session path feeds
g_game.isAttacking() into preempted/combatActive (return 'retry'), covered by
the dedicated test. No further change needed.

Driver fix surfaced by the round-trip test: the session signals route
completion via the RouteCompleted event, not the tick status, which returns
PROGRESS/NO_ACTIVE_EDGE on the tick after the route is exhausted. The driver
now maps that deterministic signal (NO_ACTIVE_EDGE only reachable after
_selectSuccessor exhausts the route, since buildRoute always selects edge 1)
to true, so the goto callback returns completion.

Full suite 1399 green; luac -p clean.
…Phase 4)

sessionNav now defaults ON: goto movement is driven by the strict S9
NavigationSession (route graph + ack'd steps) instead of legacy walkTo for
non-floor-change walking. Kept revertable via the sessionNav flag (to false).

Escape hatch: when the session reports 'retry' past the escalation threshold
(retries > 1, same threshold as legacy ignoreCreatures), the goto path falls
through to legacy walkTo so its ignoreCreatures/ignoreFields escalation and
blocks-creature kill can push past a stuck monster — GPS normally, legacy as
safety net. Session OFF / no route / terminal static failure also fall back.

Known accepted risks (user decided): (1) session mode routes the whole floor's
goto graph and returns completion at route end (per-waypoint cursor desync),
(2) needs live OTClient validation of stairs/ladders/holes + crowded rooms.

Full suite 1399 green; luac -p clean; git diff --check clean.
The OTClient sandbox 'module  not found' error came
from actions.lua's require fallback firing because the driver was never loaded
into nExBot.Nav. core/cavebot.lua explicitly safeDofiles each cavebot module
(waypoint_policy, actions, ...) and session_driver was missing from that list.

Fix: safeDofile('/cavebot/session_driver.lua') right after waypoint_policy and
before actions.lua (which references it at load time), so it self-registers
into nExBot.Nav before the goto callback needs it.

Also hardened session_driver.lua: replaced its load-time require(navigation.domain)
with a lazy first-call resolve, matching waypoint_policy's zero-load-time-dependency
pattern. safeDofile swallows load errors via pcall, so a top-level require that
failed would silently un-register the whole module and re-trigger the error.

Verified via sandbox simulation (safeDofile registers the module -> actions.lua
line 9 resolves the table, no require fallback). Full suite 1399 green.
… walkTo

The session-tick GPS driver routed movement through the whole-floor route
graph and dispatched multi-tile native autowalk chunks, which let the
client path through unseen tiles (PF_ALLOW_NOT_SEEN), making the char try
to bypass walls. Restore the legacy per-tile walkTo (canWalk-checked,
wall-avoiding native movement) as the sole mover.

Net -183 lines: removes session_driver module, sessionWalk block, and
sessionNav config; the S9 navigation engine stays for arrival detection
(ensureNavigatorRoute/hasPassedWaypoint/getNextWaypoint).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant